<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>乘法表</title>
    <style type="text/css">
        table {
            /*细边框样式，单元格之间没有间隔*/
            border-collapse: collapse;
        }
        td {
            padding: 10px;
        }
        td:hover {
            background-color: yellow;
        }
    </style>
</head>
<body>
<script type="text/javascript">

    //在js中有一个方法：prompt 对话框（输入对话框）
    var num = prompt("请输入乘法表的行数：", "9");


    document.write("<table border='1'>");
    document.write("<caption>" + num + "x" + num + "乘法表</caption>");
    //9x9乘法表
    for (var i = 1; i <= num; i++) {
        document.write("<tr>");
        for (var j = 1; j <= i; j++) {
            document.write("<td>");
            document.write(i + "&times;" + j + "=" + (i * j));
            document.write("</td>");
        }
        document.write("</tr>");
    }
    document.write("</table>");
</script>
</body>
</html>